package com.zyso.controller;

import com.zyso.dto.DetailDTO;
import com.zyso.dto.SearchDTO;
import com.zyso.service.ZySoService;
import com.zyso.vo.DetailVO;
import com.zyso.vo.SearchResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/zyso")
public class ZySoController {

    @Autowired
    private ZySoService zySoService;

    @PostMapping("/search")
    public List<SearchResultVO> search(@Validated @RequestBody SearchDTO dto, HttpServletRequest request) {
        return zySoService.searchByWb(dto.getWb(), request);
    }

    @PostMapping("/detail")
    public DetailVO detail(@Validated @RequestBody DetailDTO dto) {
        return zySoService.getDetail(dto.getSiteId(), dto.getId());
    }

}
